<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">

	$.ligerDefaults.Grid.editors['textarea'] = {
        create: function (container, editParm){
            var input = $("<textarea />");
            container.append(input);
            container.width('auto').height('auto');
            return input;
        },
        getValue: function (input, editParm){
            return input.val();
        },
        setValue: function (input, value, editParm){
            input.val(value);
        },
        resize: function (input, width, height, editParm){
            var column = editParm.column;
            input.width(column.editor.width);
            input.height(column.editor.height);
        }
    };
	
	
	var grid_ae = null;
	var dialog_ae = null;
	$(function(){
		grid_ae = $("#template_grid").ligerGrid({
                columns: [
                { display: '模板名称', name: 'name', isSort : false, width: 200},
                { display: '模板内容', name: 'source',isSort : false, width: 500,
                  editor: { type: 'textarea',height:80,width:400}
                },
                { display: '创建人', name: 'creator',isSort : false, width: 100},
                { display: '最后修改人', name: 'updater',isSort : false, width: 100},
                { display: '最后修改时间', name: 'gmtModified',isSort : false,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }
                }
                ], 
                pageSize:10,
                root :'list',
                record:'totalRecord',
                url: "/misc/template/templateGrid.htm", 
                width: '99%',height:'99%',
                rownumbers:true,
                enabledEdit: true,
                frozen:false,
                detailToEdit: true,
                onAfterSubmitEdit:onAfterSubmitEdit
            });


	});
	
	function editTemplate(name){
	
	}
	
	function search(){
		grid_ae.options.parms = [{name:'searchName',value:$("#search_name").val()}];
		grid_ae.loadData();
	}
	
	function onAfterSubmitEdit(e){
		var name = e.record.name;
		var source = e.newdata.source;
		$.post("saveTemplate.htm",{
			name:name,
			source:source
		},function(data){
		});
	}
</script>
<div id="searchbar">
   模板名：<input id="search_name" type="text" value="${searchName}"/>
    <input id="btnOK" type="button" value="查询" onclick="search()" />
</div>
<div id="template_grid" style="margin:0; padding:0"></div>
